#include "types.h"
#include <cmath>

Position::Position(){
    x = 0;
    y = 0;
}

Position::Position(int x ,int y){
    this->x = x;
    this->y = y;
}


bool Position::isPositive(){
    return (x >= 0 && y >= 0);
}


bool Position::isInside(int xmin,int ymin,int xmax, int ymax){
    if(x > xmin && x < xmax)
        if(y > ymin && y < ymax)
            return true;
        else
            return false;
    else
        return false;
}

bool Position::operator==(Position a){
    if(a.x==x)
        if(a.y == y) return true;
        else return false;
    else return false;
}

bool Position::operator!=(Position a){
    if(a.x==x)
        if(a.y == y) return false;
        else return true;
    else return true;
}

Position Position::operator+(Position a){
    Position aux;
    aux.x=x+a.x;
    aux.y=y+a.y;
    return aux;
}

R3::R3(){
    x=0;
    y=0;
    z=0;
}

R3::R3(float a,float b,float c){
    x=a;
    y=b;
    z=c;
}


bool R3::operator==(R3 a){
    if(x==a.x)
        if(y==a.y)
            if(z==a.z) return true;
            else return false;
        else return false;
    else return false;

}

bool R3::operator!=(R3 a){
    if(x==a.x)
        if(y==a.y)
            if(z==a.z) return false;
            else return true;
        else return true;
    else return true;

}

R3 R3::operator+(R3 a){
    R3 result = R3(x+a.x,y+a.y,z+a.z);
    return result;
}

R3 R3::operator-(R3 a){
    R3 result = R3(x-a.x,y-a.y,z-a.z);
    return result;
}

float R3::operator*(R3 a){
    float result = x*a.x+y*a.y+z*a.z;
    return result;
}

void R3::operator-(){
    x=(-x);
    y=(-y);
    z=(-z);
}

Point pointfromposition(Position a){
    Point p = Point(a.x,a.y);
    return p;
}

R3 R3::getNormalized(){
    float norma;
    norma = sqrt(x*x+y*y+z*z);
    Vector out = Vector(x/norma,y/norma,z/norma);
    return out;
}

void R3::normalize(){
    float norma;
    norma = sqrt(x*x+y*y+z*z);
    x=x/norma;
    y=y/norma;
    z=z/norma;
}
